package com.aaa.factory;

import com.aaa.entity.Product;
import com.aaa.feign.ProductFeign;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
// 远程调用失败就到这里，底层会生成动态代理类
@Component
public class ProductFeignFallBackFactory implements FallbackFactory<ProductFeign> {
    private static final Logger log = LoggerFactory.getLogger(ProductFeignFallBackFactory.class);

    @Override
    public ProductFeign create(Throwable cause) {
        log.info( "服务调用出现问题" + cause.getLocalizedMessage());
        return new ProductFeign() {
            @Override
            public Product getShopInfo(Long pid) {
                Product product = new Product();
                return product;
            }
        };
    }
}
